***********************************************
* Summary Statistics and Covariate Balance Tables
* (Tables 1 & 2)
***********************************************

cap log close _all
log using ../logs/summary_tables.txt, replace text nomsg name(log2)

log off log2

* Table 1 Summary Statistics of Consumer Payment Choice

use ${datafolder}/supermarket_cid_characteristics.dta, clear

global payment_to_summarize "cash_amt_pct_before cash_amt_pct_after debit_amt_pct_before debit_amt_pct_after mobile_amt_pct_before mobile_amt_pct_after credit_amt_pct_before credit_amt_pct_after" 

eststo clear
estpost tabstat ${payment_to_summarize} ///
	, statistics(count mean sd p25 p50 p75) columns(statistics)

log on log2
display "Table 1"
esttab, cells("mean(fmt(a2) label(Mean)) sd(fmt(a2) label(Std.Dev.)) p25(fmt(a2) label(25%)) p50(fmt(a2) label(50%)) p75(fmt(a2) label(75%)) ")  ///
	nostar nonumbers nomtitle label varwidth(35)
log off log2

* Table 2 Summary Statistics of Consumer Characteristics and Covariate Balance

* Panel (A) Summary Statistics of Pre-Demonetization Observable Characteristics

global spending_to_summarize_mean "spending_pre share_food_pre share_nonfood_pre share_durable_pre share_nondurable_pre"
global variety_to_summarize "variety_product_pre variety_div_pre variety_family_pre variety_shop_pre variety_trip_pre"

label variable cash_amt_pct_before "Prior cash dependence"

	
eststo clear
estpost tabstat cash_amt_pct_before ${spending_to_summarize_mean} ///
	${variety_to_summarize} ///
	, statistics(count mean sd p25 p50 p75) columns(statistics)

log on log2
display "Table 2 Panel (A)"	
esttab, cells("mean(fmt(a2) label(Mean)) sd(fmt(a2) label(Std.Dev.)) p25(fmt(a2) label(25%)) p50(fmt(a2) label(50%)) p75(fmt(a2) label(75%)) ")  ///
	nostar nonumbers nomtitle label varwidth(45)
log off log2

* Panel (B) Correlation between Treatment Intensity and Pre-Demonetization Observable Characteristics

global spending_to_summarize_mean "spending_grp100 share_food_pre share_durable_pre"

label variable spending_grp100 "Percentile rank of monthly spending"

eststo clear	
estpost correlate cash_amt_pct_before ///
	age_know_pre gender_know_pre marital_know_pre ///
	${spending_to_summarize_mean} ///
	${variety_to_summarize}
	


esttab, cell("rho p count") noobs

log on log2
display "Table 2 Panel (B)"
esttab, cell("rho(fmt(a2) label(Correlation))") ///
	noobs nonumbers nomtitle label varwidth(60)
log off log2
